/*
 *  $Id: BreathOfEternity.cs 1221 2010-11-30 16:54:52Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima.Cards001.Neutral.Spells {
    public class BreathOfEternity: SelfEnchantmentCard {
        public BreathOfEternity(): base("001_n_s_breath_of_eternity") {
            Level = CompleteLevel.ReadyForTest;
            Element = ElementType.Neutral;
            Value = 100;
            foreach (ElementType element in ElementType.ManaElements)
                AddManaCost(element, 2);
        }

        protected override void DoAction(TargetArgs<int> args) {
            foreach (ElementType element in ElementType.ManaElements) {
                args.Player.DecrementMana(element, args.Player.GetMana(element));
                args.Player.Enemy.DecrementMana(element, args.Player.Enemy.GetMana(element));
            }
            base.DoAction(args);
        }
        protected override EnchantmentAffect CreateEnchantment() {
            return new BreathOfEternityAffect();
        }

        private class BreathOfEternityAffect: EnchantmentAffect<BreathOfEternity> {
            public BreathOfEternityAffect() {
                Add(new TimeAffect(8, new BreathOfEternityAura()));
            }

            public override bool Dispellable {
                get { return false; }
            }

            public override bool Drawable {
                get { return false; }
            }
        }

        private class BreathOfEternityAura: AuraAffect {
            public BreathOfEternityAura(): base(true, true) {}

            public override string Id {
                get { return AffectManager.GetCardId<BreathOfEternity>("aura"); }
            }

            public override int AverageWeightPercent {
                get { return 200; }
            }

            protected override bool AcceptAura(AbstractObject obj) {
                return AcceptOwner(obj) && obj is Player;
            }

            protected override Affect CreateSubAffect() {
                return new BreathOfEternityAuraAffect();
            }
        }

        private class BreathOfEternityAuraAffect: SpellAffect<BreathOfEternity> {
            public BreathOfEternityAuraAffect() {
                foreach (ElementType element in ElementType.ManaElements)
                    Add(new Affects.ManaLock(element, true, false));
            }
        }
    }
}
